Skip to content

Displaying Assistant


Once Zabaan is initialized, you can show it on a given screen by calling the show function as seen below.

Show

In version 1.2.1 and newer we have added support for View based implementation. Thus show function relies on Root View of your Activity, Fragment or View (Based on your app architecture).

Also beware calling this method will clean all the state and screen information.

If you are using Viewbinding or DataBinding then you can get root view from binding class instance binding.rootView

// if using DataBinding or ViewBinding
Zabaan.getInstance().show(binding.rootView, getLifecycle());
// if using DataBinding or ViewBinding    
Zabaan.getInstance().show(binding.rootView, lifecycle)

If you are not using viewBinding or DataBinding then you can get an instance of rootview from findViewById or use getWindow().getDecorView().getRootView()

//rootview from findViewById()
Zabaan.getInstance().show(rootView, getLifecycle());
//rootview from findViewById()
Zabaan.getInstance().show(rootview, lifecycle)

If rootView is not accessible directly use the method shared below.

Zabaan.getInstance().show(getWindow().getDecorView().getRootView(), getLifecycle());
Zabaan.getInstance().show(window.decorView.rootView, lifecycle)

Side effect of show

Calling this method removes all the state and screen information which was set before. Ideally show should be the first method you call in your activity or fragment in onResume to make sure previous instances of assistant and listeners are cleared and as an added bonus it also stops any ongoing interaction.

Back to top